package com.work.yshop.model;

import java.io.Serializable;

/**
 * 商品实体类
 */
public class Product implements Serializable {

    private int id;
    private String name;
    private double price;
    private int stock;
    private String description;
    private String category;
    private String imageUrl;
    private int status; // 1: 上架，0: 下架
    private String publishDate;
    private String updateDate;
    
    // 添加缺少的字段
    private double originalPrice; // 原价
    private String unit; // 单位
    private int salesCount; // 销量
    private boolean isNew; // 是否新品
    private String origin; // 产地
    private int sellerId; // 卖家ID
    private Shop shop; // 店铺信息
    private String specification; // 规格
    private String shelfLife; // 保质期
    private String features; // 特点
    private float rating; // 评分

    public Product() {
    }

    // 原有构造函数
    public Product(int id, String name, double price, int stock, String description, String category, String imageUrl, int status, String publishDate, String updateDate) {
        this.id = id;
        this.name = name;
        this.price = price;
        this.stock = stock;
        this.description = description;
        this.category = category;
        this.imageUrl = imageUrl;
        this.status = status;
        this.publishDate = publishDate;
        this.updateDate = updateDate;
    }
    
    // 添加与HomePresenter中使用的构造函数匹配的构造函数
    public Product(int id, String name, String description, double price, double originalPrice, String unit, int salesCount, String imageUrl) {
        this.id = id;
        this.name = name;
        this.description = description;
        this.price = price;
        this.originalPrice = originalPrice;
        this.unit = unit;
        this.salesCount = salesCount;
        this.imageUrl = imageUrl;
        this.status = 1; // 默认上架
        this.stock = 100; // 默认库存
    }
    
    // 添加与YshopRepository中使用的构造函数匹配的构造函数
    public Product(long id, String name, String description, double price, int inventory, String category, String imageUrl, long sellerId, long status) {
        this.id = (int)id;
        this.name = name;
        this.description = description;
        this.price = price;
        this.stock = inventory;
        this.category = category;
        this.imageUrl = imageUrl;
        this.sellerId = (int)sellerId;
        this.status = (int)status;
    }
    
    // 添加与ProductListActivity中使用的构造函数匹配的构造函数
    public Product(int id, String name, String description, double price, String imageUrl, float rating, int salesCount) {
        this.id = id;
        this.name = name;
        this.description = description;
        this.price = price;
        this.imageUrl = imageUrl;
        this.rating = rating;
        this.salesCount = salesCount;
        this.status = 1; // 默认上架
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public int getStock() {
        return stock;
    }

    public void setStock(int stock) {
        this.stock = stock;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getImageUrl() {
        return imageUrl;
    }

    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getPublishDate() {
        return publishDate;
    }

    public void setPublishDate(String publishDate) {
        this.publishDate = publishDate;
    }

    public String getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(String updateDate) {
        this.updateDate = updateDate;
    }
    
    // 添加缺少的getter和setter方法
    
    public double getOriginalPrice() {
        return originalPrice;
    }

    public void setOriginalPrice(double originalPrice) {
        this.originalPrice = originalPrice;
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    public int getSalesCount() {
        return salesCount;
    }

    public void setSalesCount(int salesCount) {
        this.salesCount = salesCount;
    }

    public boolean isNew() {
        return isNew;
    }

    public void setNew(boolean isNew) {
        this.isNew = isNew;
    }

    public String getOrigin() {
        return origin;
    }

    public void setOrigin(String origin) {
        this.origin = origin;
    }
    
    public int getInventory() {
        return stock; // 返回stock作为库存
    }
    
    public void setInventory(int inventory) {
        this.stock = inventory; // 设置stock作为库存
    }
    
    public int getSellerId() {
        return sellerId;
    }
    
    public void setSellerId(int sellerId) {
        this.sellerId = sellerId;
    }
    
    public Shop getShop() {
        return shop;
    }
    
    public void setShop(Shop shop) {
        this.shop = shop;
    }
    
    public String getSpecification() {
        return specification;
    }
    
    public void setSpecification(String specification) {
        this.specification = specification;
    }
    
    public String getShelfLife() {
        return shelfLife;
    }
    
    public void setShelfLife(String shelfLife) {
        this.shelfLife = shelfLife;
    }
    
    public String getFeatures() {
        return features;
    }
    
    public void setFeatures(String features) {
        this.features = features;
    }
    
    public float getRating() {
        return rating;
    }
    
    public void setRating(float rating) {
        this.rating = rating;
    }
    
    // 获取店铺名称
    public String getShopName() {
        return shop != null ? shop.getName() : "";
    }
    
    // 获取店铺商品数量
    public int getShopProductsCount() {
        return shop != null ? shop.getProductCount() : 0;
    }
} 